from pywinauto.application import Application
import time
import pywinauto

def intelunison(eventPar):
    # 链接已启动的unison
    app = Application(backend='uia').connect(title='Intel® Unison™')
    # 找到任务栏点击unison图标显示在台前
    app_icons = Application(backend='uia').connect(class_name='Shell_TrayWnd')
    unison_icons = app_icons['任务栏']
    unison_icons.child_window(title="Intel® Unison™ - 1 个运行窗口",auto_id="AppUp.IntelTechnologyMDE_8j3eq9eme6ctt!App", control_type="Button").click()
    # 获取unison窗口
    dlg = app["Intel® Unison™"]
    # 获取侧边栏控件
    menu = dlg['GroupBox0']
    # 获取通话控件并点击
    telButton = menu.child_window(title="通话", control_type="Button")
    telButton.click()
    time.sleep(0.5)
    dialinput = menu.child_window(title='输入电话号码', control_type='Edit')
    dialinput.set_focus()
    time.sleep(0.5)
    pywinauto.keyboard.send_keys(eventPar)
    time.sleep(0.5)
    # 移动至拨号键
    dailButton = menu.child_window(title="电话", control_type="Button")
    dailButton.click()
    # 点击使用手机
    time.sleep(0.5)
    callWin = Application(backend='uia').connect(title='OngoingCallWindow')
    callWin_dlg = callWin['OngoingCallWindow']
    callWin_dlg.child_window(title="ExpandButton",control_type="Button").click()
    callWin_dlg.child_window(title="使用手机", control_type="Button").click()


if __name__ == '__main__':
    intelunison('10086')